/**
 * 项目名：admin
 * 包名：com.xuebang.admin.service
 * 文件名：suggestionService.java
 * 版本信息：@version 1.0
 * 日期：2014-1-19-上午10:42:45
 */
package com.xuebang.admin.service;

import java.util.List;

import javax.inject.Inject;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.xuebang.admin.dao.Finder;
import com.xuebang.admin.dao.Pagination;
import com.xuebang.admin.dao.Finder.Query;
import com.xuebang.admin.entity.NewsTitle;
import com.xuebang.admin.entity.Suggestion;
import com.xuebang.admin.mapper.SuggestionMapper;

/**
 * 项目名称：admin
 * 类名称：SuggestionController
 * 类描述：
 * 创建人：liulina
 * 创建时间：2016-2-29 下午17:08:48
 * 修改人：
 * 修改时间：
 * 修改备注：
 * @version 
 */
@Service
public class SuggestionService {

	@Inject
	Finder finder;
	
	@Inject
	SuggestionMapper suggestionMapper;
	
	@Transactional(readOnly = true)
	public List<Suggestion> loadSuggestions(){
		
		return suggestionMapper.loadSuggestions();
	}
	/**
	 * 获得所有
	 * 
	 * @param intNewsLimit
	 *            限定条数
	 */
	@Transactional(readOnly = true)
	public Pagination<Suggestion> getSuggestionInfo(String searchText, Integer pageNo, Integer pageLimit) {
		
		Query que = finder.from("suggestion");
		if (searchText != null && !"".equals(searchText.trim())) {
			que.where("sign", searchText);
		}
		que.orderBy(" create_date desc");
		return que.paginate(Suggestion.class,pageNo,pageLimit);
	}
	
	@Transactional(readOnly = true)
	public Suggestion loadSuggestion(int intid){
		
		return suggestionMapper.loadsuggestion(intid);
	}
	/**
	 * 通过dianhua名字查找s
	 * 
	 * @param String phone
	 */
	@Transactional(readOnly = true)
	public List<Suggestion> searchByphone(String phone){
		
		return suggestionMapper.searchBySuggestion(phone);
	}

	
	/**
	 * 更
	 * 
	 * @param menusuggestion
	 */
	@Transactional(rollbackFor = Exception.class)
	public void updatesuggestion(Suggestion suggestion){
		suggestionMapper.updatesuggestion(suggestion);
	}
	
	/**
	 * 删除问题
	 * 
	 * @param menusuggestion
	 */
	@Transactional(rollbackFor = Exception.class)
	public void deletesuggestions(String strsuggestionIDs){
		suggestionMapper.deletesuggestions(strsuggestionIDs.split(","));
	}
	
	/**
	 * 搜索
	 * 
	 * @param searchText 搜索内容
	 */
	public Pagination<Suggestion> searchSuggestion(String contents, int intPageNo,int intPageLimit){
		Query que = null;
		if (contents != null && !"".equals(contents.trim())) {
			 que = finder.from("suggestion").like("sign",contents);
		}else{
			 que = finder.from("suggestion");
		}
		
		que.orderBy("create_date desc");
		return que.paginate(Suggestion.class, intPageNo, intPageLimit);
	}
	
}
